import service from '/@/utils/request';

export const useAttendRuleCreateApi = (formData: object) => {
    return service({
        url: `v0/attend/rule/create`,
        method: 'POST',
        data: formData
    });
}

export const useAttendRuleDeleteApi = (param: string | string[]) => {
    let arrList: string[] = []

    if (param instanceof Array) {
        arrList = param
    } else {
        arrList.push(param)
    }

    return service({
        url: `v0/attend/rule/delete`,
        method: 'DELETE',
        data: { codeList: arrList }
    });
}

export const useAttendRuleUpdateApi = (formData: object) => {
    return service({
        url: `v0/attend/rule/update`,
        method: 'PUT',
        data: formData
    });
}

export const useAttendRuleQueryApi = (code: string,) => {
    return service({
        url: `v0/attend/rule/query`,
        method: 'GET',
        params: { code: code },
    });
}

export const useAttendRulePageApi = (formData?: object) => {
    return service({
        url: `v0/attend/rule/page`,
        method: 'POST',
        data: formData
    });
}

export const useAttendRuleListApi = () => {
    return service({
        url: `v0/attend/rule/list`,
        method: 'GET',
    });
}

/**关联角色*/
export const useAttendRuleAddRoleApi = (formData?: object) => {
    return service({
        url: `v0/attend/rule/addRole`,
        method: 'POST',
        data: formData
    });
}
export const useAttendRuleRemoveRoleApi = (formData?: object) => {
    return service({
        url: `v0/attend/rule/removeRole`,
        method: 'DELETE',
        data: formData
    });
}

/**关联人员 */
export const useAttendRuleAddEmployeeApi = (formData?: object) => {
    return service({
        url: `v0/attend/rule/addEmployee`,
        method: 'POST',
        data: formData
    });
}
export const useAttendRuleRemoveEmployeeApi = (formData?: object) => {
    return service({
        url: `v0/attend/rule/removeEmployee`,
        method: 'DELETE',
        data: formData
    });
}
export const useAttendRuleEmployeePageApi = (formData?: object) => {
    return service({
        url: `v0/attend/rule/employeePage`,
        method: 'POST',
        data: formData
    });
}

/**关联部门 */
export const useAttendRuleAddOrgApi = (formData?: object) => {
    return service({
        url: `v0/attend/rule/addOrg`,
        method: 'POST',
        data: formData
    });
}
export const useAttendRuleRemoveOrgApi = (formData?: object) => {
    return service({
        url: `v0/attend/rule/removeOrg`,
        method: 'DELETE',
        data: formData
    });
}
